package com.example.fresheveryday.controller;


import com.example.fresheveryday.po.Banner;
import com.example.fresheveryday.restful.JsonResult;
import com.example.fresheveryday.service.BannerService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ll
 * @since 2023-07-5
 */
@RestController
@RequestMapping("/banner")
public class BannerController {
    @Autowired
    BannerService bannerService;
    @RequestMapping("/list")
    public List<Banner> list(){
        return bannerService.list();
    }
    @RequestMapping("saveorupdate")
    public JsonResult saveorupdat(@RequestBody Banner banner){
        bannerService.saveOrUpdate(banner);
        return JsonResult.success("success");
    }
    @RequestMapping("getbyid")
    public Banner getbyid(int id){
        return bannerService.getById(id);
    }
    @RequestMapping("del")
    public JsonResult del(int id){
        bannerService.removeById(id);
        return JsonResult.success("success");
    }

}
